package models

import (
	"fitness-srv/basic/config"
	"gorm.io/gorm"
)

// 教练
type Coach struct {
	gorm.Model
	UserId   int    `json:"user_id" gorm:"type:int;comment:'用户id'"`
	Mobile   string `json:"mobile" gorm:"type:char(11);comment:'手机号'"`
	Password string `json:"password" gorm:"type:varchar(32);comment:'密码'"`
	Comment  string `json:"comment" gorm:"type:varchar(300);comment:'评价'"`
	Status   int    `json:"status" gorm:"type:int;comment:'状态 1-空闲中 2-忙碌中'"`
}

func (co *Coach) TableName() string {
	return "coach"
}

func (co *Coach) AddComment(id int64) error {
	return config.DB.Model(Coach{}).Where("id = ?", id).Updates(&co).Find(&co).Error
}
